function scientificNotationToString(param) {
    const strParam = String(param);
    const flag = /e/.test(strParam);
    if (!flag) return param;
  
    // 指数符号 true: 正，false: 负
    let sysbol = true;
    if (/e-/.test(strParam)) {
      sysbol = false;
    }
    // 指数
    const index = Number(strParam.match(/\d+$/)[0]);
    // 基数
    // eslint-disable-next-line no-useless-escape
    const basis = strParam.match(/^[\d\.]+/)[0].replace(/\./, "");
    if (sysbol) {
      return basis.padEnd(index + 1, 0);
    } else {
      return basis.padStart(index + basis.length, 0).replace(/^0/, "0.");
    }
  } // 科学计数法转
  
  // 字符串截取小数点后N位
  const SubString = (data, num = 1) => {
    if(data==0){
      return 0
    }
    if(!data){
      return '--'
    }
    let fill = "";
    // let s = Number(value).toFixed(18) + "";
    const value = scientificNotationToString(data);
    let s = value + "";
  
    const nums = Number(num);
    for (let i = 0; i < nums; i++) {
      fill += "0";
    }
  
    if (value === undefined || isNaN(value)) {
      return 0 + "." + fill;
    }
  
    if (s.indexOf(".") !== -1) {
      s += fill;
      s = s.substring(0, s.indexOf(".") + nums + 1);
      return s - 0;
    } else {
      return s ;
    }
  };


  // 时分秒
  const hms = (value, type = 0) => {
    if (!value) {
      return;
    }
    var date = new Date(value); // 时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var h = date.getHours();
    h = h < 10 ? "0" + h : h;
    var m = date.getMinutes();
    m = m < 10 ? "0" + m : m;
    var s = date.getSeconds();
    s = s < 10 ? "0" + s : s;
    if (type === 0) {
      return h + ":" + m + ":" + s;
    } else if (type === 1) {
      if (value >= 3600000) {
        return h + ":" + m + ":" + s;
      } else {
        return m + ":" + s;
      }
    }
  };


  // 年月日
  const ynd = value => {
    if (!value) {
      return "------";
    }
    var date = new Date(value); // 时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var Y = date.getFullYear() + "-";
    var M =
      (date.getMonth() + 1 < 10
        ? "0" + (date.getMonth() + 1)
        : date.getMonth() + 1) + "-";
    var D = date.getDate();
    D = D < 10 ? "0" + D : D;
    var h = date.getHours();
    h = h < 10 ? "0" + h : h;
    var m = date.getMinutes();
    m = m < 10 ? "0" + m : m;
    var s = date.getSeconds();
    s = s < 10 ? "0" + s : s;
    return Y + M + D;
  };
  // 年月
  const yn = value => {
    if (!value) {
      return "------";
    }
    var date = new Date(value); // 时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var Y = date.getFullYear() ;
    var M =
      (date.getMonth() + 1 < 10
        ? "0" + (date.getMonth() + 1)
        : date.getMonth() + 1) ;
  
    return `${Y}年${M}月` ;
  };
  // 年月日时分秒
  const yndhms = value => {
    if (!value) {
      return "------";
    }
    var date = new Date(value); // 时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var Y = date.getFullYear() + "-";
    var M =
      (date.getMonth() + 1 < 10
        ? "0" + (date.getMonth() + 1)
        : date.getMonth() + 1) + "-";
    var D = date.getDate();
    D = D < 10 ? "0" + D : D;
    var h = date.getHours();
    h = h < 10 ? "0" + h : h;
    var m = date.getMinutes();
    m = m < 10 ? "0" + m : m;
    var s = date.getSeconds();
    s = s < 10 ? "0" + s : s;
    return Y + M + D + "       " + h + ":" + m + ":" + s;
  };

  const cutdown = value => {
    if (value) {
      const type = Math.floor(value / 1000);
      let second = Math.floor(value / 1000); // 未来时间距离现在的秒数
      let day = Math.floor(second / 86400); // 整数部分代表的是天；一天有24*60*60=86400秒 ；
      // day = day < 10 ? "0" + day : day;
      second = second % 86400; // 余数表示剩下的秒数
      let hour = Math.floor(second / 3600); // 整数部分代表小时；
      second %= 3600; // 余数代表 剩下的秒数；
      let minute = Math.floor(second / 60);
      second %= 60;
      day = day < 10 ? "0" + day : day;
      hour = hour < 10 ? "0" + hour : hour;
      minute = minute < 10 ? "0" + minute : minute;
      second = second < 10 ? "0" + second : second;
  
      if (type >= 86400) {
        return day + ":" + hour + ":" + minute + ":" + second;
      } else if (type < 86400 && type >= 3600) {
        return hour + ":" + minute + ":" + second;
      } else if (type < 3600 && type > 0) {
        return minute + ":" + second;
      } else {
        return "00:00:00";
      }
    } else {
      return "00:00:00";
    }
  };
  // 手机号加密
  const encryptionphone = value => {
    const reg = new RegExp(
      "^[A-Za-z\\d]+([-_.][A-Za-z\\d]+)*@([A-Za-z\\d]+[-.])+[A-Za-z\\d]{2,4}$"
    );
  
  
    if (value){
      if (reg.test(value)) {
        return value.substr(0, 3) + "****" + value.substr(-9);
      } else {
        return value.substr(0, 3) + "****" + value.substr(-4);
      }
    }else{
      return "------"
    }
  };


  export default {
    subString:SubString,
    substring:SubString,
    hms,
    ynd,
	ymd:ynd,
    yn,
    yndhms,
    cutdown,
    encryptionphone
  };
  